//
//  MoneyDetailViewController.m
//  xxShare
//
//  Created by 柳麟喆 on 2018/3/31.
//  Copyright © 2018年 lzLiu. All rights reserved.
//

#import "MoneyDetailViewController.h"
#import "moneyDetailTableViewCell.h"
#import "OneFeedViewController.h"
#import "AwardModel.h"

@interface MoneyDetailViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong)UITableView *tableview;
@property(nonatomic, copy)NSMutableArray *testData;

@end

@implementation MoneyDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"我的明细";
    
    _tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.llz_width, self.view.llz_height) style:UITableViewStyleGrouped];
    _tableview.tableHeaderView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, CGFLOAT_MIN)];
    _tableview.sectionFooterHeight = 1;
    _tableview.dataSource = self;
    _tableview.delegate = self;
    _tableview.backgroundColor = BACKGROUND_COLOR;
    [self.view addSubview:_tableview];
    [_tableview registerNib:[UINib nibWithNibName:@"moneyDetailTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"moneyDetailTableViewCell"];
    
    _testData = [[NSMutableArray alloc]init];
    _testData = [self addTestData];
}

#pragma mark - *******tableviewDelegate dataSource*******

- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
    static NSString *identify = @"moneyDetailTableViewCell";
    moneyDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identify forIndexPath:indexPath];
    cell.model = _testData[indexPath.row];
    return cell;
}

- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _testData.count;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 100;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView cellForRowAtIndexPath:indexPath].selected = NO;
    OneFeedViewController *one = [[OneFeedViewController alloc]init];
    one.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:one animated:YES];
}
- (NSMutableArray *)addTestData{
    NSMutableArray *Data = [[NSMutableArray alloc]init];
    NSArray *avatorArr = @[@"avator2.png",@"avator3.png",@"avator4.png",@"avator5.png"];
    NSArray *nameArr = @[@"叮当猫",@"哪吒",@"球球",@"可达鸭"];
    NSArray *timeArr = @[@"2018-3-29",@"2018-3-28",@"2018-3-27",@"2018-3-21"];
    NSArray *moneyArr = @[@"+192.1",@"+18.3",@"+42.1",@"+23.8"];
    NSArray *typeArr = @[@"作品奖励发放",@"利息发放",@"利息发放",@"作品奖励发放"];
    for (int i = 1; i < 5; i++) {
        NSDictionary* dic = @{@"avator":avatorArr[i-1],
                              @"name":nameArr[i-1],
                              @"time":timeArr[i-1],
                              @"money":moneyArr[i-1],
                              @"awardType":typeArr[i-1]
                              };
        AwardModel *model = [[AwardModel alloc]initWithAwardModel:dic];
        [Data addObject:model];
    }
    return Data;
}

@end
